/*
 * @Author: Jimmy
 * @LastModifiedBy: Jimmy
 * @Date: 2024-05-25 17:25:04
 * @LastEditTime: 2024-07-07 15:02:22
 * @FilePath: /nest_study/server/src/modules/system/role/dto/index.dto.ts
 */
import { ApiProperty } from "@nestjs/swagger";
import { IsArray, IsNumber, IsNumberString, IsOptional, IsString, Length } from "class-validator";
import { BaseInfoDto, PaginationDto } from "src/common/dto/index.dto";

export class CreateRoleDto extends BaseInfoDto {
    @ApiProperty({ required: true })
    @IsString()
    @Length(0, 30)
    name: string;

    @ApiProperty({ required: true })
    @IsString()
    @Length(0, 100)
    code: string;

    @IsOptional()
    @IsArray()
    menuIds?: Array<number>;

    @IsOptional()
    @IsArray()
    menus?: Array<any>;
}

export class UpdateRoleDto extends CreateRoleDto {
    @ApiProperty({
        required: true
    })
    @IsNumber()
    id: number
}

export class ListRoleDto extends PaginationDto {
    @ApiProperty({ required: false })
    @IsOptional()
    @IsString()
    @Length(0, 30)
    name?: string;

    @ApiProperty({ required: false, default: 0, description: '是否显示对应的菜单权限 0 显示  1不显示' })
    @IsOptional()
    @IsNumberString()
    showMenu: number;
}

export class AuthRoleDto {
    @ApiProperty({
        required: false
    })
    @IsArray()
    ids: number[]
}

export class findRoleDto {
    @ApiProperty({
        required: true
    })
    @IsNumberString()
    id: number
}

export class DeleteRolerDto {
    @ApiProperty({
        required: true
    })
    @IsArray()
    ids: number[]
}
